priv->name = NULL;
priv->user_alpha = 255;
priv->alpha = 255;
- priv->surface = NULL;
priv->parent = NULL;
priv->first_child = NULL;
priv->last_child = NULL;
}
}
+static GdkSurface *
+gtk_widget_get_surface (GtkWidget *widget)
+{
+ GtkNative *native = gtk_widget_get_native (widget);
+
+ if (native)
+ return gtk_native_get_surface (native);
+
+ return NULL;
+}
+
/**
* gtk_widget_realize:
* @widget: a #GtkWidget
*
* Creates the GDK (windowing system) resources associated with a
- * widget. For example, @widget->surface will be created when a widget
- * is realized. Normally realization happens implicitly; if you show
+ * widget. Normally realization happens implicitly; if you show
* a widget and all its parent containers, then the widget will be
* realized and mapped automatically.
*
gtk_widget_update_input_shape (widget);
if (priv->multidevice)
- gdk_surface_set_support_multidevice (priv->surface, TRUE);
+ {
+ GdkSurface *surface = gtk_widget_get_surface (widget);
+
+ gdk_surface_set_support_multidevice (surface, TRUE);
+ }
gtk_widget_update_alpha (widget);
*
* This function is only useful in widget implementations.
* Causes a widget to be unrealized (frees all GDK resources
- * associated with the widget, such as @widget->surface).
+ * associated with the widget).
**/
void
gtk_widget_unrealize (GtkWidget *widget)
if (priv->realized)
{
- return gdk_surface_get_frame_clock (priv->surface);
+ GdkSurface *surface = gtk_widget_get_surface (widget);
+
+ return gdk_surface_get_frame_clock (surface);
}
else
{
gtk_widget_real_can_activate_accel (GtkWidget *widget,
guint signal_id)
{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GdkSurface *surface;
/* widgets must be onscreen for accels to take effect */
- return gtk_widget_is_sensitive (widget) &&
- _gtk_widget_get_mapped (widget) &&
- gdk_surface_is_viewable (priv->surface);
+ if (!gtk_widget_is_sensitive (widget) ||
+ !_gtk_widget_get_mapped (widget))
+ return FALSE;
+
+ surface = gtk_widget_get_surface (widget);
+
+ return gdk_surface_is_viewable (surface);
}
/**
gint
gtk_widget_get_scale_factor (GtkWidget *widget)
{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkRoot *root;
GdkDisplay *display;
GdkMonitor *monitor;
g_return_val_if_fail (GTK_IS_WIDGET (widget), 1);
if (_gtk_widget_get_realized (widget))
- return gdk_surface_get_scale_factor (priv->surface);
+ {
+ GdkSurface *surface = gtk_widget_get_surface (widget);
+
+ if (surface)
+ return gdk_surface_get_scale_factor (surface);
+ }
root = _gtk_widget_get_root (widget);
if (root && GTK_WIDGET (root) != widget)
void
gtk_widget_error_bell (GtkWidget *widget)
{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkSettings* settings;
gboolean beep;
+ GdkSurface *surface;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!settings)
return;
+ surface = gtk_widget_get_surface (widget);
+
g_object_get (settings,
"gtk-error-bell", &beep,
NULL);
- if (beep && priv->surface)
- gdk_surface_beep (priv->surface);
+ if (beep && surface)
+ gdk_surface_beep (surface);
}
static void
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
- if (GTK_IS_NATIVE (widget))
- {
- priv->surface = gtk_native_get_surface (GTK_NATIVE (widget));
- g_object_ref (priv->surface);
- }
- else
- {
- g_assert (priv->parent);
- priv->surface = priv->parent->priv->surface;
- g_object_ref (priv->surface);
- }
-
priv->realized = TRUE;
gtk_widget_connect_frame_clock (widget);
gtk_widget_disconnect_frame_clock (widget);
priv->realized = FALSE;
-
- g_clear_object (&priv->surface);
}
void
from_surface = _gtk_widget_get_device_surface (from, device);
if (!from_surface)
- from_surface = from->priv->surface;
+ from_surface = gtk_widget_get_surface (from);
gdk_surface_get_device_position (from_surface, device, &x, &y, NULL);
gtk_widget_handle_crossing (from, &crossing, x, y);
{
to_surface = _gtk_widget_get_device_surface (to, device);
if (!to_surface)
- to_surface = to->priv->surface;
+ to_surface = gtk_widget_get_surface (to);
crossing.direction = GTK_CROSSING_IN;
gdk_surface_get_device_position (to_surface, device, &x, &y, NULL);
static void
gtk_widget_update_input_shape (GtkWidget *widget)
{
- GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
+ GdkSurface *surface;
+
+ surface = gtk_widget_get_surface (widget);
/* set shape if widget has a GDK surface already.
* otherwise the shape is scheduled to be set by gtk_widget_realize().
*/
- if (priv->surface)
+ if (surface)
{
cairo_region_t *region;
cairo_region_t *csd_region;
else
region = NULL;
- gdk_surface_input_shape_combine_region (priv->surface, region, 0, 0);
+ gdk_surface_input_shape_combine_region (surface, region, 0, 0);
if (free_region)
cairo_region_destroy (region);
priv->multidevice = (support_multidevice == TRUE);
if (_gtk_widget_get_realized (widget))
- gdk_surface_set_support_multidevice (priv->surface, support_multidevice);
+ {
+ GdkSurface *surface = gtk_widget_get_surface (widget);
+
+ if (surface)
+ gdk_surface_set_support_multidevice (surface, support_multidevice);
+ }
}
/* There are multiple alpha related sources. First of all the user can specify alpha
{
if (GTK_IS_NATIVE (widget))
{
- gdk_surface_set_opacity (priv->surface, priv->alpha / 255.0);
+ gdk_surface_set_opacity (gtk_native_get_surface (GTK_NATIVE (widget)), priv->alpha / 255.0);
gtk_widget_queue_allocate (widget);
}
else